package com.macrounion.atv.service.entity.ext;

import com.macrounion.atv.service.entity.ProtocolC;

public class ProtocolCExt extends ProtocolC implements Comparable<ProtocolCExt> {
    @Override
    public int compareTo(ProtocolCExt o) {
        String oChannelCode = o.getChannelCode();
        String thisChannelCode = this.getChannelCode();
        if (oChannelCode == null) {
            oChannelCode = "";
        }
        if (thisChannelCode == null) {
            thisChannelCode = "";
        }
        if (oChannelCode.startsWith("t")) {
            oChannelCode = oChannelCode.substring(1);
        }
        if (thisChannelCode.startsWith("t")) {
            thisChannelCode = thisChannelCode.substring(1);
        }
        if (!thisChannelCode.equals(oChannelCode)) {
            return Integer.parseInt(thisChannelCode) - Integer.parseInt(oChannelCode);
        } else {
            return this.getCreatedTime().compareTo(o.getCreatedTime());
        }
    }
}
